//
//  CertificateQueryViewController.h
//  CommunityNannyO2O
//
//  Created by apple on 15/8/13.
//  Copyright (c) 2015年 Apple. All rights reserved.
//

#import "CertificateQueryViewController.h"
#import "APIAdress.h"
#import "MBProgressHUD+YC.h"
#import "MJExtension.h"
#import "AccountTool.h"
#import "AppConfig.h"
#import "QXNetWorkTool.h"
#import "CertificateQueryTableCell.h"

@interface CertificateQueryViewController()<QXNetWorkToolDelegate,
    UITableViewDataSource,UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation CertificateQueryViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tableView.dataSource = self;
    
    self.tableView.delegate = self;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

-(void)configNavigationItem
{
    self.navigationItem.title = @"证书查询";
    [self.navigationController.navigationBar setTranslucent:NO];
    
    [self.navigationController.navigationBar
     setBackgroundImage:[UIImage imageNamed:@"bg_navigation_bar"]
     forBarMetrics:UIBarMetricsDefault];
    
    //status bar的字体为白色
    //导航栏的背景色是黑色
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0],UITextAttributeTextShadowColor,[UIFont fontWithName:@"Hiragino Sans GB" size:18.0],NSFontAttributeName,nil]];
    
    [self configNavigationBackAction:^{
        
        [self.navigationController popViewControllerAnimated:YES];
    }];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 606;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    CertificateQueryTableCell *cell = [CertificateQueryTableCell cellWithTableView:tableView];
    
//    if (self.model.id == nil) {
//        [cell.infoData addObject:@""];
//    } else {
//        [cell.infoData addObject:self.model.id];
//    }
    
    if (self.model.real_name == nil) {
        [cell.infoData addObject:@""];
    } else {
        [cell.infoData addObject:self.model.real_name];
    }
    
    if (self.model.sex == nil) {
        [cell.infoData addObject:@""];
    } else {
        
        NSString *sex;
        if ([self.model.sex isEqualToString:@"1"])
        {
            sex = @"男";
        }
        else
        {
            sex = @"女";
        }
        [cell.infoData addObject:sex];
    }

    if (self.model.nationality == nil) {
        [cell.infoData addObject:@""];
    } else {
        [cell.infoData addObject:self.model.nationality];
    }

    if (self.model.people == nil) {
        [cell.infoData addObject:@""];
    } else {
        [cell.infoData addObject:self.model.people];
    }

    if (self.model.midi_id == nil) {
        [cell.infoData addObject:@""];
    } else {
        [cell.infoData addObject:self.model.midi_id];
    }
    
    if (self.model.major_name == nil)
    {
        [cell.infoData addObject:@""];
    }
    else
    {
        [cell.infoData addObject:self.model.major_name];
    }
    
    if (self.model.grade_num == nil)
    {
        [cell.infoData addObject:@""];
    }
    else
    {
        [cell.infoData addObject:self.model.grade_num];
    }
    
    if (self.model.certificate_date == nil)
    {
        [cell.infoData addObject:@""];
    }
    else
    {
        [cell.infoData addObject:self.model.certificate_date];
    }
    
    if (self.model.start_end_grade == nil)
    {
        [cell.infoData addObject:@""];
    }
    else
    {
        [cell.infoData addObject:self.model.start_end_grade];
    }
    
    if (self.model.certificate_num == nil)
    {
        [cell.infoData addObject:@""];
    }
    else
    {
        [cell.infoData addObject:self.model.certificate_num];
    }
    
    return cell;
}

-(void)useMethodToFindBlackLineAndHind
{
    UIImageView* blackLineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
    
    blackLineImageView.hidden = YES;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self configNavigationItem];
    
    [self useMethodToFindBlackLineAndHind];
}

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    

}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}


@end




















